import React from "react";
import PropTypes from "prop-types";

export default class ImageText extends React.Component{

	// 木偶组件

	constructor(){
		super();
		this.state = {
			imagetextNews:[]
		}
	}

	componentDidMount(){
		var result = fetch("http://www.wwtliu.com/sxtstu/news/juhenews.php?type="+this.props.type+"&count="+this.props.count,{
			method:"get"
		})
		.then(res => {
			return res.json();
		})
		.then(json => {
			this.setState({
				imagetextNews:json
			})
		})
	}

	render(){

		var {imagetextNews} = this.state;

		return(
			<div className="imagetext">
				{
					imagetextNews.map((item,index) => {
						return (
							<div className="itBlock">
								<img src={item.thumbnail_pic_s} alt=""/>
								<p>{item.title}</p>
							</div>
						)
					})
				}
			</div>
		)
	}
}

ImageText.propTypes = {
	type:PropTypes.string,
	count:PropTypes.number
}